//
//  XsTableView.m
//  GameBaby
//
//  Created by keyZhang on 13-12-27.
//  Copyright (c) 2013年 keyZhang. All rights reserved.
//

#import "XsTableView.h"
#import "GiftTableViewCell.h"
#import "GiftDetailViewController.h"
#import "GiftCellModel.h"

@implementation XsTableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


- (void)awakeFromNib
{
    [super awakeFromNib];
    self.rowHeight = 80.0;
    self.dataSource = self;
    self.delegate =self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/


#pragma mark -UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *identifier = @"GiftCell";
    GiftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"GiftTableViewCell" owner:self options:nil] lastObject];
    }
    cell.model = self.dataList[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [super tableView:tableView didSelectRowAtIndexPath:indexPath];
    GiftDetailViewController *gditailVC = [[GiftDetailViewController alloc] init];
    gditailVC.detailID = [(GiftCellModel *)self.dataList[indexPath.row] gameId];
    [self.viewController.navigationController pushViewController:gditailVC animated:YES];
}

@end
